/*
 * @Author: 哈尔滨大拐 3181845089@qq.com
 * @Date: 2022-08-09 10:25:43
 * @LastEditors: 哈尔滨大拐 3181845089@qq.com
 * @LastEditTime: 2022-08-09 14:46:34
 * @FilePath: \mygit\js\blog2.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
(function () {
    

  //首页博客只取前六个
    const articleWrap = document.querySelector('#blog1 .article-wrap')
    const url = 'http://81.70.162.221:3000/getBlogs'
    // console.log(url);
    axios.get(url , {
      params: {
        pageNum: 1,
        pageSize: 6
    }
    }).then(function (response) {
      let blogs = response.data.data;
      console.log(blogs);
      // blogs = Array.from('blogs')
      blogs.forEach(blog => {
        articleWrap.insertAdjacentHTML('beforeend', `
        <article>
        <a href="blog-single.html?id=${blog.id}"><img src="http://81.70.162.221:3000/${blog.image}" alt=""></a>
        <div class="content-wrap">
          <a href="blog-single.html?id=${blog.id}">
            <h3>${blog.title}</h3>
          </a>
          <p>${blog.abstract}</p>
          <div class="flex justify-content-between align-items-center">
            <span class="date"><i class="iconfont qm-clock"></i>${getFullDay(new Date())}</span>
            <a class="more" href="blog-single.html?id=${blog.id}">查看更多<i class="iconfont qm-arrow-right"></i></a>
          </div>
        </div>
      </article>
    `);
      });
    });
  
    
  })()
  
  
  